#include "Asteroid.h"

Asteroid::Asteroid(int a_size)
{
	 size = a_size;
}
Asteroid::Asteroid(XY startPos, int a_size)
{
	Velocity.x = 0; Velocity.y = 0;
	pos = startPos;
	size = a_size;
}


XY Asteroid::GetPos()
{
	return pos;
}

int Asteroid::GetSize()
{
	return size;
}


bool Asteroid::IsDead()
{
	return (size <= 0);
		

}


void Asteroid::Destroy()
{
	
	if(size <= 1){ size = 0; return;}//VON:  TODO FIX THIS SO IT IS NOT RETARDIFICATION.jpg
	
	int numNewAsteroids = 1 + rand() % (size-1); // should roll from 1 to size.  this is the number of new asteroids to create
	for(int i = 0; i < numNewAsteroids && size != 1; i++)
	{
		int newAsteroidSize = rand() % size;
		size -= newAsteroidSize;
		Asteroid* nAster = new Asteroid(pos, newAsteroidSize);
		nAster->asteroidVec = asteroidVec;
		float newVel = rand() % 100 + 0.1f ;

		SetMagAccordingToAngleXY(nAster->Velocity,  2 * PI *((rand() % 1000) / 1000.0f), newVel); //(2pi ) / degrees = radians
		SetMagAccordingToAngleXY(Velocity,  2 * PI *((rand() % 1000) / 1000.0f), newVel); //(2pi ) / degrees = radians
 		asteroidVec->push_back( nAster);
		size = size;
	}

	

}

